package com.kudian.restful.controller;

import com.kudian.common.persistence.ResultObj;
import com.kudian.common.utils.StringUtils;
import com.kudian.restful.entity.LoginSession;
import com.kudian.restful.service.AppVersionService;
import com.kudian.restful.service.CartService;
import com.kudian.restful.service.LoginSessionService;
import com.kudian.restful.vo.appversion.AppVersionRetVO;
import com.kudian.restful.vo.appversion.AppVersionVO;
import com.kudian.restful.vo.cart.AddCartInfoVO;
import com.kudian.restful.vo.cart.QueryCartInfoRetVO;
import com.kudian.restful.vo.cart.QueryCartInfoVO;
import com.wordnik.swagger.annotations.ApiOperation;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2016/4/27.
 */
@RestController
@RequestMapping("appversion")
public class AppVersionController {

    private static final Logger logger = Logger.getLogger(AppVersionController.class);

    @Autowired
    private AppVersionService appVersionService;

    @Autowired
    private LoginSessionService loginSessionService;

    @RequestMapping(value = "query", method = RequestMethod.POST)
    @ApiOperation(value = "取得当前最新版本号", httpMethod = "POST", notes = "取得当前最新版本号  phoneSys字段 1: android 2: ios, appType: 1:商户版 2:用户版 ", response = AppVersionRetVO.class)
    public @ResponseBody AppVersionRetVO query(@RequestBody AppVersionVO vo) {
        AppVersionRetVO o = new AppVersionRetVO();

        try {
            o = appVersionService.getCurrentVersion(vo);
            o.setErrcode(0);
            o.setErrmsg("成功取得当前最新版本号");
        } catch (Exception e) {
            o.setErrcode(9999);
            o.setErrmsg("取得当前最新版本号失败");
            logger.error(e);
        }
        return o;
    }

}
